﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Battle
{
    public class PlaybackBattleOver : IBattleOver
    {
        OnBattleResult onResult;

        public PlaybackBattleOver(OnBattleResult onResult)
        {
            this.onResult = onResult;
        }

        public void End()
        {
            UnityEngine.Debug.Log("Server Result: " + remoteResult);
            UnityEngine.Debug.Log("Client Result: " + localResult);
            if (onResult != null)
            {
                onResult(remoteResult);
            }
        }


        bool remoteResult;
        bool localResult;

        public void Excute()
        {
            localResult = BattleManager.Instance.battleViewCtrl.winCamp == BattleCamp.Attacker;
            ProtoBuf.Message.SCFightPlayback msg = StaticData.lastBattleEndMsg as ProtoBuf.Message.SCFightPlayback;
            remoteResult = msg.serverResult == 1 ? true : false;

            End();
        }

        public BattleType GetBattleType()
        {
            return StaticData.curBattleData.battleType;
        }
    }
}
